stage.set_background("halfcourt")
sprite = codesters.Sprite("player4", -175, -150)
net = codesters.Sprite("basketballnet", 215, 175)
instructions = codesters.Text("Click on the sprite to shoot the basketball. Hit the basket to score a point!", 0, 50, "white")
stage.set_gravity(10)
sprite.set_gravity_off()
score = 0
score_display = codesters.Display(score, -200, 150)
def click(sprite):
ball = codesters.Sprite("basketball", -150, -100)
ball.set_x_speed(10)
ball.set_y_speed(10)
sprite.event_click(click)
def collision(net, hit_sprite):
global score
my_var = hit_sprite.get_name()
if my_var == "basketball":
hit_sprite.hide()
score += 1
score_display.update(score)
net.event_collision(collision)
stage.disable_right_wall()
tester = TestManager()
tester.display_success_message("Great job! Click Submit and Next to continue!")
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)